﻿using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using Newtonsoft.Json;
using SqlSugar;

namespace Aioms.Models
{
    ///<summary>
    ///报修工单表
    ///</summary>
    [SugarTable("nrworkorder")]
    public class NrWorkOrder
    {
        public NrWorkOrder()
        {
            this.Created = DateTime.Now;
            this.Updated = DateTime.Now;
        }
        /// <summary>
        /// 工单ID
        /// </summary>           
        [SugarColumn(IsPrimaryKey = true, IsIdentity = true, ColumnName = "id")]
        [JsonProperty("id")]
        public long Id { get; set; }

        /// <summary>
        /// 企业ID
        /// </summary>   
        [SugarColumn(ColumnName = "eid")]
        [JsonProperty("eid")]
        public long Eid { get; set; }

        /// <summary>
        /// 引用来源ID
        /// </summary>   
        [SugarColumn(ColumnName = "npid")]
        [JsonProperty("npid")]
        public long NpId { get; set; }

        /// <summary>
        /// Desc:故障等级
        /// Default:
        /// Nullable:True
        /// </summary>           
        [SugarColumn(ColumnName = "level")]
        [JsonProperty("level")]
        public int Level { get; set; }

        /// <summary>
        /// 工单单号
        /// </summary>    
        [SugarColumn(ColumnName = "number")]
        [JsonProperty("number")]
        public string Number { get; set; }

        /// <summary>
        /// 工单名称
        /// </summary>    
        [SugarColumn(ColumnName = "name")]
        [JsonProperty("name")]
        public string Name { get; set; }

        /// <summary>
        /// 设备id
        /// </summary>           
        [SugarColumn(ColumnName = "dvid")]
        [JsonProperty("dvid")]
        public long Dvid { get; set; }

        /// <summary>
        /// Desc:设备名称
        /// Default:
        /// Nullable:True
        /// </summary>           
        [SugarColumn(ColumnName = "dvname")]
        [JsonProperty("dvname")]
        public string Dvname { get; set; }

        /// <summary>
        /// 维修工时
        /// </summary>
        [SugarColumn(ColumnName = "manhour")]
        [JsonProperty("manhour")]
        public string ManHour { get; set; }

        /// <summary>
        /// 维修结果
        /// </summary>
        [SugarColumn(ColumnName = "sjresult")]
        [JsonProperty("sjresult")]
        [DisplayFormat(ConvertEmptyStringToNull = false)]
        public string SjResult { get; set; } = "";

        /// <summary>
        /// 实际排故流程
        /// </summary>
        [SugarColumn(ColumnName = "sjprocedure", ColumnDescription = "实际排故流程")]
        [JsonProperty("sjprocedure")]
        [DisplayFormat(ConvertEmptyStringToNull = false)]
        public string SjProcedure { get; set; } = "";

        /// <summary>
        /// 维修开始时间
        /// </summary>           
        [SugarColumn(ColumnName = "begintime")]
        [JsonProperty("begintime")]
        public DateTime BeginTime { get; set; }

        /// <summary>
        /// 维修结束时间
        /// </summary>           
        [SugarColumn(ColumnName = "endtime")]
        [JsonProperty("endtime")]
        public DateTime EndTime { get; set; }

        /// <summary>
        /// 实际维修开始时间
        /// </summary>           
        [SugarColumn(ColumnName = "sjbegintime")]
        [JsonProperty("sjbegintime")]
        public DateTime SjBeginTime { get; set; } = DateTime.MinValue;

        /// <summary>
        /// 实际维修结束时间
        /// </summary>           
        [SugarColumn(ColumnName = "sjendtime")]
        [JsonProperty("sjendtime")]
        public DateTime SjEndTime { get; set; } = DateTime.MinValue;

        /// <summary>
        /// 实际工时
        /// </summary>  
        [SugarColumn(ColumnName = "sjman_hour")]
        [JsonProperty("sjman_hour")]
        [DisplayFormat(ConvertEmptyStringToNull = false)]
        public string SjManHour { get; set; } = "";

        /// <summary>
        /// 实际图片
        /// </summary>           
        [SugarColumn(ColumnName = "sjimageurl", ColumnDataType = "json", IsJson = true)]
        [JsonProperty("sjimageurl")]
        [DisplayFormat(ConvertEmptyStringToNull = false)]
        public List<string> SjImgUrl { get; set; } = new();

        /// <summary>
        /// 实际视频
        /// </summary>           
        [SugarColumn(ColumnName = "sjvideourl", ColumnDataType = "text")]
        [JsonProperty("sjvideourl")]
        [DisplayFormat(ConvertEmptyStringToNull = false)]
        public string SjVideoUrl { get; set; } = "";

        /// <summary>
        /// 指派人ID，逗号分隔：1,2,3
        /// </summary>  
        [SugarColumn(ColumnName = "epids")]
        [JsonProperty("epids")]
        public string Epids { get; set; }

        /// <summary>
        /// 指派人姓名，逗号分隔：张三,李四,王五
        /// </summary>  
        [SugarColumn(IsIgnore = true)]
        [JsonProperty("eprealnames")]
        public string EpRealnames { get; set; } = "";

        /// <summary>
        /// 图片
        /// </summary>           
        //[SugarColumn(ColumnName = "imageurl")]
        //[JsonProperty("imageurl")]
        //public string ImgUrl { get; set; }

        /// <summary>
        /// 视频
        /// </summary>           
        //[SugarColumn(ColumnName = "videourl")]
        //[JsonProperty("videourl")]
        //public string VideoUrl { get; set; }

        /// <summary>
        /// 语音
        /// </summary>           
        //[SugarColumn(ColumnName = "voiceurl")]
        //[JsonProperty("voiceurl")]
        //public string VoiceUrl { get; set; }

        /// <summary>
        /// 工单状态
        /// </summary>           
        [SugarColumn(ColumnName = "status")]
        [JsonProperty("status")]
        public string Status { get; set; }

        /// <summary>
        /// 实际维修人ID
        /// </summary>           
        [SugarColumn(ColumnName = "sjwxepid")]
        [JsonProperty("sjwxepid")]
        public long SjWxEpId { get; set; }

        /// <summary>
        /// 实际维修人姓名
        /// </summary>           
        [SugarColumn(ColumnName = "sjwxeprealname")]
        [JsonProperty("sjwxeprealname")]
        public string SjWxEpRealname { get; set; } = "";

        /// <summary>
        /// 
        /// </summary>           
        [SugarColumn(ColumnName = "created", IsOnlyIgnoreUpdate = true)]
        [JsonProperty("created")]
        public DateTime Created { get; set; }

        /// <summary>
        /// 
        /// </summary>           
        [SugarColumn(ColumnName = "updated")]
        [JsonProperty("updated")]
        public DateTime Updated { get; set; }

        [SugarColumn(IsIgnore = true)]
        [JsonProperty("noticerepair")]
        public NoticeRepair NoticeRepair { get; set; }

    }
}
